package sg.nus.iss.vmcs.guilisteners;

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import sg.nus.iss.vmcs.controllers.TransactionController;

/**
 * Action Listener for the Drink Selection Items in the Drink Selection Box
 * @author Philip Chew
 */
public class DrinkSelectionListener implements ActionListener {
	
	/**Transaction Controller*/
	private TransactionController transCtrl;
	
	/**
	 * Creates new instance of Drink Selection Listener
	 * @param transCtrl Instance of TransactionController
	 */
	public DrinkSelectionListener(TransactionController transCtrl) {
		this.transCtrl = transCtrl;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() instanceof Button) {
			transCtrl.startTransaction(Integer.parseInt(((Button)e.getSource()).getActionCommand()));
		}
	}
}
